<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let date = new Date();
        console.log(date);

        let date2 = new Date('2022-5-02 20:59:59');
        console.log(date2)

        let timestamp = date.getTime();

        let date3 = new Date(timestamp);
        console.log(date3)

        let date4 = new Date(2022, 4, 20);
        console.log(date4)

        //获取年份
        console.log(date.getFullYear());

        //获取月份，从0开始算，比现在的月份少1
        console.log(date.getMonth());

        //获取天数,从1 开始算
        console.log(date.getDate());

        //获取星期几
        console.log(date.getDay());

        //setDate法根据本地时间来指定一个日期对象的天数，返回值，指定日期的当前的时分秒
        let date5 = new Date();
        let returns=date5.setDate(19);
        console.log(returns);

        //获取这个月第一天的00:00:00 的时间戳
        //1.获取这个月，第一天的当前的时分秒
        let date6 = new Date();
        let timeStam6=date6.setDate(1);
        //2.根据时间戳，创建当前的对象
        let date7=new Date(timeStam6);
        let dateStr=date7.getFullYear()+'-'+(date7.getMonth()+1)+'-'+date7.getDate()
        console.log(dateStr);
        let date8 = new Date(dateStr);
        console.log(date8.getTime());
        //toLocaleDateString() 方法返回该日期对象日期部分的字符串，该字符串格式因不同语言而不同
        console.log(date8);
        console.log(date8.toLocaleDateString())

        //2022-5-20 14:41,通过 获取年份，月份... 拼接起来

        //怎么获取这个月的最后一天23:59:59的时间戳

        //借助 setMonth实现该题目

        let date9 = new Date();

        let currMoney=date9.getMonth();

        let newxMoney = currMoney+1;

        console.log(date9.setMonth(newxMoney))
        let date10=new Date(newxMoney);
        let dateStr2=date10.getFullYear()+'/'+date10.getMonth()+'/1';
        new Date(dateStr2).getTime()



    </script>
</body>

</html>